<template>
	<div>
		<!-- 面包屑导航区 -->
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item>首页</el-breadcrumb-item>
			<el-breadcrumb-item>订单管理</el-breadcrumb-item>
			<el-breadcrumb-item>订单列表</el-breadcrumb-item>
			<el-breadcrumb-item>订单修改</el-breadcrumb-item>
		</el-breadcrumb>
		<el-form :model="orderlist" ref="orderlist" label-width="100px" style="margin-top: 20px;width: 50%;margin-left: 20%;">
			<el-form-item label="用户编号" prop="user_id">
				<el-input v-model="orderlist.user_id"></el-input>
			</el-form-item>
			<el-form-item label="订单编号" prop="goods_id">
				<el-input v-model="orderlist.goods_id"></el-input>
			</el-form-item>
			<el-form-item label="订单时间" prop="order_time">
				<el-input v-model="orderlist.order_time"></el-input>
			</el-form-item>
			<el-form-item label="订单状态" prop="order_status">
				<el-select v-model="orderlist.order_status" placeholder="请选择">
					<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item style="float: right;">
				<el-button type="primary" @click="submit()">修改</el-button>
				<el-button @click="reset('orderlist')">重置</el-button>
				<el-button type="info" @click="goBack()">返回</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
import axios from "axios";
export default{
	name: "editorder",
	data(){
		return{
			 options: [{
			 	value: '进行中',
			 	label: '进行中'
			 }, {
			 	value: '已完成',
			 	label: '已完成'
			 }, {
			 	value: '异常',
			 	label: '异常'
			 }],
			 orderlist: {},
		}
	},
	methods:{
		getInfo(){
			let id = this.$route.query.order_id;
			axios.get('http://localhost:8080/order/findById?order_id='+id)
			.then(res=>{
				this.orderlist = res.data;
			});
		},
		submit(){
			axios.post("http://localhost:8080/order/update", this.orderlist)
			.then(res=>{
				console.log(res.data);
				this.$message('修改订单成功！');
				history.back();
			},err=>{
				console.log(err);
			})
		},
		reset(formName){
			this.$refs[formName].resetFields();
		},
		goBack(){
			history.back();
		}
	},
	created(){
		this.getInfo();
	}
}
</script>

<style>
</style>
